package cn.iocoder.yudao.module.member.dal.mysql.userpromotionrecords;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.controller.app.userpromotionrecords.vo.AppUserPromotionRecordsGroupRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.userpromotionrecords.UserPromotionRecordsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.userpromotionrecords.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 用户推广记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface UserPromotionRecordsMapper extends BaseMapperX<UserPromotionRecordsDO> {

    default PageResult<UserPromotionRecordsDO> selectPage(UserPromotionRecordsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserPromotionRecordsDO>()
                .betweenIfPresent(UserPromotionRecordsDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UserPromotionRecordsDO::getInviterUserId, reqVO.getInviterUserId())
                .eqIfPresent(UserPromotionRecordsDO::getInviteeUserId, reqVO.getInviteeUserId())
                .orderByDesc(UserPromotionRecordsDO::getId));
    }

    default List<UserPromotionRecordsDO> selectByInviterUserId(Long inviterUserId) {
        return selectList(UserPromotionRecordsDO::getInviterUserId, inviterUserId);
    }

    default UserPromotionRecordsDO selectByInviteeUserId(Long inviteeUserId) {
        return selectOne(UserPromotionRecordsDO::getInviteeUserId, inviteeUserId);
    }

    AppUserPromotionRecordsGroupRespVO groupByInviterUserId(@Param("inviterUserId") Long inviterUserId);

}